package top.shaozuo.simple.user.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

import org.apache.commons.lang.StringUtils;
import org.eclipse.microprofile.config.Config;

import top.shaozuo.simple.user.web.listener.ServletConfigHolder;
import top.shaozuo.web.mvc.PageController;

/**
 * 从Config中获取配置
 * 
 * @author shaozuo
 *
 */
@Path("/threadconfig")
public class ThreadConfigController implements PageController {

	@POST
	@GET
	@Path("/info")
	@Override
	public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Config config = ServletConfigHolder.getConfig();
		String propertName = request.getParameter("pName");
		if (StringUtils.isNotBlank(propertName)) {
			String value = config.getValue(propertName, String.class);
			request.setAttribute("pName", propertName);
			request.setAttribute("pValue", value);
		}
		return "threadconfigInfo.jsp";
	}

}
